﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HRM.DAL.DAO;
using HRM.DAL.Gateway;

namespace HRM.BLL
{
    public class CodeManager
    {
        CodeGateway gateway=new CodeGateway();
        public Code GenerateNewCode()
        {
            CodePrefix prefix=new CodePrefix();
            prefix = prefix.GetCodePrefix();

            Code code=new Code();
            code = gateway.GetLastEmployeeNumber();

            code.Number = code.Number +1;
            code.CodeName = prefix.Prefix + (code.Number+prefix.Number);
            return code;
        }
        public bool SaveCode()
        {
            Code code = new Code();
            code=GenerateNewCode();
            return gateway.SaveCode(code);
        }

        public int GetEmpCodeId(string codeName)
        {
            return gateway.GetEmpCodeId(codeName);
        }
    }
}